package com.ourteam.scm.utils;

import java.util.HashMap;
import java.util.Map;

public class SCMServiceFactory {
	
	private static Map<SCMServerBean,ISCMService> scmServiceMap = new HashMap<SCMServerBean,ISCMService>();

	public static ISCMService getSCMService(SCMServerBean scmServerBean) throws Exception{
		
		if(scmServiceMap.containsKey(scmServerBean) == false){
			
			if(SCMServerBean.SVN_SERVER.equals(scmServerBean.getScmType())){
				scmServiceMap.put(scmServerBean, new SVNServiceImpl(scmServerBean));
			}
			else if(SCMServerBean.GIT_SERVER.equals(scmServerBean.getScmType())) {
				scmServiceMap.put(scmServerBean, new GitServiceImpl(scmServerBean));
			}
			
		}
		
		return scmServiceMap.get(scmServerBean);
	}
}
